package com.exahq.controller;


import com.exahq.common.lang.Result;
import com.exahq.entity.User;
import com.exahq.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 关注公众号：MarkerHub
 * @since 2021-01-23
 */
@RestController
@RequestMapping(value = "/user")
public class UserController {
        @Autowired
        UserService userService;

        @RequiresAuthentication
        @GetMapping("/index")
        public Result index() {
            User user = userService.getById(1L);
            return Result.succ(user);
        }

        @PostMapping("/save")
        public Result save(@Validated @RequestBody User user) {
            return Result.succ(user);
        }

 /*   @RequiresAuthentication
    @GetMapping(value = "/index")
    public  Object index(){

        return Result.succ(userService.getById(1));
    }*/

    /**
     * 测试实体校验
     * @param user
     * @return
     */
   /* @PostMapping(value = "/save")
    public Object testUser(@Validated @RequestBody User user) {
        System.out.println("");
        return  Result.succ(user);
    }*/

}
